<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" v-show="showSearch" :inline="true">
      <el-form-item label="班次" prop="timeShiftName">
        <el-select
          v-model="queryParams.timeShiftName"
          placeholder="班次"
          clearable
          size="small"
          style="width: 240px"
        >
          <el-option
            v-for="dict in timeShiftList"
            :key="dict.value"
            :label="dict.label"
            :value="dict.label"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="渠道商" prop="companyName">
        <el-input
          v-model="queryParams.companyName"
          placeholder="请输入渠道商"
          clearable
          size="small"
          style="width: 200px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="姓名" prop="workerName">
        <el-input
          v-model="queryParams.workerName"
          placeholder="请输入姓名"
          clearable
          size="small"
          style="width: 200px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

      <el-row :gutter="10" class="mb8">
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
      </el-row>


     <el-table v-loading="loading" :data="employmentPlanDetailList" >
<!--       <el-table-column type="selection" width="40" align="center"/>
      <el-table-column label="序号"  type="index" width="60" align="center"/>-->
      <el-table-column label="姓名" prop="workerName" width="100"/>
      <el-table-column label="身份证" prop="idCard" :show-overflow-tooltip="true" width="200"/>
      <el-table-column label="联系电话" prop="phoneCode" :show-overflow-tooltip="true" width="120"/>
       <el-table-column label="班组"  prop="groupName" align="center" width="100"/>
       <el-table-column label="班次"  prop="timeShiftName" align="" width="100"/>
       <el-table-column label="性别" align="center" prop="sex" width="100">
        <template slot-scope="scope">
          <div v-if="scope.row.sex == 1">男</div>
          <div v-else-if="scope.row.sex == 2">女</div>
        </template>
      </el-table-column>
       <el-table-column label="招聘渠道" prop="companyName" width="100"/>
       <el-table-column label="来源渠道" prop="sourceFlag" width="100">
         <template slot-scope="scope">
           <div v-if="scope.row.sourceFlag == 1">excel导入</div>
           <div v-else-if="scope.row.sourceFlag == 2">小程序</div>
         </template>
       </el-table-column>
       <el-table-column label="是否签到" prop="sourceFlag" width="100">
         <template slot-scope="scope">
           <div v-if="scope.row.status == 1">未签到</div>
           <div v-else-if="scope.row.status != 1">已签到</div>
         </template>
       </el-table-column>
      <el-table-column label="备注" align="center" prop="remark" width="100"/>

       <el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-width">
         <template slot-scope="scope">


           <el-button
             v-if="scope.row.sourceFlag==1 "
             size="mini"
             type="text"
             icon="el-icon-delete"
             @click="handleDelete(scope.row)"
             v-hasPermi="['job:employmentPlan:detail:remove']"
           >移除名单</el-button>
         </template>
       </el-table-column>
    </el-table>
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />

  </div>
</template>

<script>
import {listEmploymentPlan,delEmployment} from "@/api/job/employmentPlan/employmentPlanApi";
import { getToken } from "@/utils/auth";
export default {
  name: "detail",
  created() {
    this.getList();

  },
  data() {
    return {
      sexOptions:[{value: 1, label: '男'}, {value: 2, label: '女'}],
      timeShiftList:[{value: 1, label: '白班'}, {value: 2, label: '夜班'}],

      signUpLoading:true,
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 表格数据
      employmentPlanDetailList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 是否显示弹出层（数据权限）
      openDataScope: false,
      menuExpand: false,
      menuNodeAll: false,
      deptExpand: true,
      deptNodeAll: false,
      // 日期范围
      dateRange: [],
      signUp:false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        //渠道名称
        groupName: undefined,
        //联系人
        workerName: undefined,
        workTime: this.$route.query.workTime,
        orderCode: this.$route.query.orderCode,
      },


      // 表单参数
      form: {},
      defaultProps: {
        children: "children",
        label: "label"
      },

    };
  },


  methods: {

    /** 获取员工信息列表 */
    getList() {
      this.loading = true;
      listEmploymentPlan(this.addDateRange(this.queryParams, this.dateRange)).then(
        response => {
          this.employmentPlanDetailList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },

    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },

    /** 删除按钮操作 */
    handleDelete(row) {
      const id = row.id || this.ids
      this.$confirm('是否确认删除编号为"' + id + '"的数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function() {
        return delEmployment(id);
      }).then(() => {
        this.getList();
        this.msgSuccess("删除成功");
      }).catch(() => {});
    },

  }
};
</script>
